import numpy as np

"""
1、创建简单矩阵
"""
a = np.mat('5 6;7 8')
print(a)

b = np.mat([[5, 6], [7, 8]])
print(b)

print(type(a), type(b))  # 矩阵

n1 = np.array([[5, 6], [7, 8]])
print(type(n1))  # 数组

"""
2、使用mat函数创建常见的矩阵
"""
# 创建3*3的零矩阵
d1 = np.mat(np.zeros((3, 3)))
print(d1)

# 创建2*4的1矩阵
d2 = np.mat(np.ones((2, 4)))
print(d2)

# 创建[0,1)随机矩阵
d3 = np.mat(np.random.rand(3, 4))
print(d3)

# 创建[1,8)随机矩阵
d4 = np.mat(np.random.randint(1, 8, size=(3, 5)))
print(d4)

# 对角矩阵
d5 = np.mat(np.eye(5, 5))
print(d5)

# 对角线矩阵
d6 = np.mat(np.diag([1, 2, 3]))
print(d6)

d7 = np.mat(np.diag([7, 8, 9]))
print(d7)